package com.itcast.web.controller;


import com.itcast.pojo.User;
import com.itcast.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
   @Autowired
   private UserService userService;

    @RequestMapping("/findall")
    @ResponseBody
    public List<User> findall(){
       return userService.findall();
    }

    @RequestMapping("/findbyId")
    @ResponseBody
    public User findbyId(int id){
       return userService.findbyId(id);
    }

    @RequestMapping("/update")
    @ResponseBody
    public void update(@RequestBody User user){
        userService.update(user);
    }

}
